package com.cskaoyan.controller;

import com.cskaoyan.service.user.UserService;
import com.cskaoyan.vo.user.DataVo;
import com.cskaoyan.vo.BaseRespVo;
import com.cskaoyan.vo.user.UserListVo;

import com.cskaoyan.vo.BaseRespVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @Autowired
    UserService userService;

    // ?page=1&limit=20&sort=add_time&order=desc
    @RequestMapping("admin/user/list")
    @RequiresPermissions("admin:user:list")
    public BaseRespVo list(String username, String mobile, Integer page, Integer limit, String sort, String order) {
        UserListVo userListVo = userService.query(username, mobile, page, limit, sort, order);

        return BaseRespVo.ok(userListVo);
    }

    @RequestMapping("admin/address/list")//收货地址
    @RequiresPermissions("admin:address:list")
    public BaseRespVo addressList(String name,Integer userId,Integer page, Integer limit, String sort, String order) {
        DataVo dataVo = userService.addressQuery(name,userId,page, limit, sort, order);
        return BaseRespVo.ok(dataVo);
    }

    @RequestMapping("admin/collect/list")
    @RequiresPermissions("admin:collect:list")
    public BaseRespVo collect(Integer userId, Integer valueId, Integer page, Integer limit, String sort, String order) {

        DataVo dataVo = userService.collectQuery(userId, valueId, page, limit, sort, order);
        return BaseRespVo.ok(dataVo);

    }
    @RequestMapping("admin/feedback/list")
    @RequiresPermissions("admin:feedback:list")
    public BaseRespVo feedback(String username, Integer id, Integer page, Integer limit, String sort, String order){
       DataVo dataVo = userService.feedbackQuery(username,id,page,limit,sort,order);
       return BaseRespVo.ok(dataVo);
    }

    @RequestMapping("admin/footprint/list")
    @RequiresPermissions("admin:footprint:list")
    public BaseRespVo footprint(Integer goodsId, Integer userId, Integer page, Integer limit, String sort, String order) {
        DataVo dataVo = userService.footprintQuery(goodsId, userId, page, limit, sort, order);
        return BaseRespVo.ok(dataVo);
    }

    @RequestMapping("admin/history/list")
    @RequiresPermissions("admin:history:list")
    public BaseRespVo history(Integer userId, String keyword, Integer page, Integer limit, String sort, String order) {
        DataVo dataVo = userService.historyQuery(userId, keyword, page, limit, sort, order);
        return BaseRespVo.ok(dataVo);
    }

}